package geo.model.wps
{
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.geom.Matrix;
	import flash.text.TextFormat;
	
	import geo.model.wps.ProcessDescription;
	
	import mx.collections.ArrayList;
	import mx.containers.Canvas;
	import mx.core.UITextField;
	import mx.graphics.ImageSnapshot;
	
	import spark.components.TextArea;
	
	/**
	 * Execute extends the flash.display.Shape object. That way it is easily diagrammable.
	 * The final Object built to be easily marshalled into the WPS Execute XML.
	 * This Execute Object is marshalled to XML then sent (HTTP POST) to the WPS Server.
	 * The manipulation of this object and its related inputs, response format, etc occurs
	 * in the workflow (diagram) triggered upon a DropEvent.
	 */
	public class Execute extends Canvas
	{
		
		public function Execute(x:Number, y:Number, id:String = null){
			super();
			if(id != null) {
				this.identifier = id;
			} else if (this.description.identifier != null){
				this.identifier = this.description.identifier;
			} else {
				this.identifier = "process";
			}
			this.width = 100;
			this.height = 50;
			this.x = x;
			this.y = y;
			var default_bg_color:uint = 0x0099FF;
			this.setStyle("backgroundColor", default_bg_color);
			this.setStyle("cornerRadius", 10);
			this.setStyle("borderStyle","solid");
			this.setStyle("borderColor","black");
			this.setStyle("borderThickness",10);
			this.setLabel(this.identifier,this.x/2,this.y/2);
		}
		
		/**
		 * String identifier (process name).
		 * &lt;ows:Identifier>JTS:intersection&lt;/ows:Identifier>
		 * By Default exclude namespace... 'JTS:intersection' becomes 'intersection' to the user.
		 */
		public var identifier:String;
		
		/**
		 * Description object contains the response from Describe Process.
		 * Provides input, output, abstract.
		 * @see Description
		 */
		public var description:ProcessDescription;
		
		/**
		 * DataInputs ArrayCollection of Input objects.
		 * This can contain another process (subprocessing).
		 *       &lt;wps:Data>
		 *		&lt;wps:ComplexData mimeType="text/xml; subtype=gml/3.1.1"><![CDATA[...]]>&lt;/wps:ComplexData>
		 *	&lt;/wps:Data>
		 */
		public var dataInputs:ArrayList;
		
		/**
		 * Response format is the output format selected from the Description.outputFormat List.
		 *   <code>&lt;wps:ResponseForm>
		 * 		&lt;wps:RawDataOutput mimeType="text/xml; subtype=gml/3.1.1">
		 *			&lt;ows:Identifier>result&lt;/ows:Identifier>
		 *		&lt;/wps:RawDataOutput>
		 *	&lt;/wps:ResponseForm><code>
		 */
		public var responseFormat:String;
		
		private function setLabel(text:String,ex:Number,why:Number):void	{
			var uit:UITextField = new UITextField();
			uit.text = text;
			uit.width = this.width-10;
			uit.height = this.height-10;
			uit.x = this.width /2 - uit.width /2;
			uit.y = this.height /2 - uit.height /2;
			//TextFormat class does not work here for some reason.
			
			this.addChild(uit);
		}

	}
}